window.addEventListener('load',function() {

    // 轮播图

    // 点击换图
    var iot_Slideshow = document.querySelector('#iot_Slideshow');
    console.log('iot_Slideshow');
    var ul = iot_Slideshow.querySelector('ul');
    var circle = document.querySelector('.iot_circle');
    for (var i = 0; i < circle.children.length; i++) {
        circle.children[i].setAttribute('data-index',i);
        circle.children[i].addEventListener('click',function() {
            ul.id = 'img'+(this.dataset['index'] - 1 + 2);
            k = this.dataset['index'] -0 + 1;
            for (var i = 0; i < circle.children.length; i++) {
                circle.children[i].id = '';
            }
            this.id ='cur';
        })
    }

    // 自动换图
    k = 1;
    var k = setInterval(function() {
        
    ul.id = 'img' + k;
    for (var j = 0; j < circle.children.length; j++) {
        circle.children[j].id = '';
    }
    circle.children[k - 1].id ='cur';
    k++;
    if (k > 5) {
         k = 1;
    }
    },3000);

    // 下拉菜单
    var menu = document.querySelector('.iot_2navmenu');
    var iot_2nav = document.querySelector('.iot_2nav') ;
    var a = iot_2nav.querySelectorAll('a');
    console.log(menu);
    for (var i = 2; i <= 7 ; i++) {
        a[i].onmouseover = function( e ) {
            menu.id = 'iot_2navmenu';
        }
        a[i].onmouseout = function() {
            menu.id = '';
        }
    }

    var banner = document.querySelector('.iot_banner');
    var wrapper = banner.querySelector('.iot_wrapper');
    var bannerul = wrapper.querySelector('ul');
    console.log(bannerul.children);
    var bannermenu = wrapper.querySelectorAll('.iot_bannermenu');
    for (var i = 0 ; i < 8; i++) {
        bannerul.children[i].setAttribute('data-index',i);
        bannerul.children[i].onmouseover = function() {
            l = this.dataset['index'] - 0;
            bannermenu[l].id = 'iot_bannermenu' ;
        }
        bannerul.children[i].onmouseout = function() {
            bannermenu[l].id = ''
        }
        bannermenu[i].onmouseover = function(){
            this.id = 'iot_bannermenu' ;
        }
        bannermenu[i].onmouseout = function() {
            this.id = ''
        }
    }
    
    var input =  document.querySelector('input');
    var iot_search = document.querySelector('.iot_search');
    var searchdiv = iot_search.querySelector('div');
    input.addEventListener('click',function() {
        searchdiv.id = 'iot_searchdiv';
    })
    input = setInterval(function() {
        searchdiv.id = '';
    },30000)
})